#!/bin/bash
# verify test

fname=f`date +%H%M%S`
mkdir $fname
for i in $(seq 0 50); do
  echo $i
  nachos -x ../test/testmatmult -rs $i > $fname/out$i
  s1=`cat $fname/out$i| grep -i '7220'|wc -l`
  #if [cat $fname/out$i| grep -i '7220' > /dev/null
  if [ "$s1" -ne "2" ]
  then echo "../test/testmatmult $i : error ending\n" >> $fname/error; fi

  nachos -x ../test/testmatmult1 -rs $i > $fname/out1$i
  s2=`cat $fname/out1$i| grep -i '7220'|wc -l`
  #if ! cat $fname/out$i| grep -i '7220' > /dev/null
  if [ "$s2" -ne "2" ]
  then echo "../test/testmatmult1 $i : error ending\n" >> $fname/error; fi

  nachos -x ../test/testmatmult -rs $i -P RAND > $fname/out0$i
  s11=`cat $fname/out0$i| grep -i '7220'|wc -l`
  #if [cat $fname/out$i| grep -i '7220' > /dev/null
  if [ "$s11" -ne "2" ]
  then echo "../test/testmatmult rand $i : error ending\n" >> $fname/error; fi

  nachos -x ../test/testmatmult1 -rs $i -P RAND > $fname/out11$i
  s22=`cat $fname/out11$i| grep -i '7220'|wc -l`
  #if ! cat $fname/out$i| grep -i '7220' > /dev/null
  if [ "$s22" -ne "2" ]
  then echo "../test/testmatmult1 rand $i : error ending\n" >> $fname/error; fi

#  for (( j=0; j < 12; j++))
#  do
#    cat $fname/out$i | grep -i "Group\ \[$j\]" >> $fname/resort$i
#    echo '\n' >> $fname/resort$i
#    if cat $fname/out$i|grep -i "Group\ \[$j\]" > /dev/null
#    then
#      if ! cat $fname/out$i|grep -i "Group\ \[$j\]\ is\ leaving\ TicketTaker" > /dev/null
#      then echo "test $i : group $j error ending" >> $fname/error; fi
#    fi
#  done
done

